home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
array.lha
/
array
/
README
< prev
Wrap
Text File
|
1993-08-08
|
2KB
|
50 lines
verview.
his is a C++ class for simple fixed arrays with arbitrary integer
ower and upper bounds and index range checking. Simple design and
mplementation was a major development goal. The array class uses
ssertions to check various error conditions, including index
ut-of-range and failed memory allocation. Failed assertions cause
rogram termination, and possibly a core dump.
he element type must have a default constructor (a constructor that
akes no arguments) or be of a type that does not need a constructor,
uch as, integers and other built-in types. It must also be possible
o assign to the element type, and to destroy elements.
would be grateful for any comments and/or suggestions. Please
-mail to dag@control.lth.se.
ompilation.
his is a template class, so it requires a compiler which can handle
uch beasts, for example, AT&T version 3.0. Minor changes may be
eeded to compile it with g++ (not tested).
aveats.
he copy-constructor of the array should use the copy-constructor of the
lement type to initialize its elements. Unfortunately, the obvious
olution does not seem to compile with cfront 3.0.1, so I have chosen
o explicitly outlaw copy-construction of arrays, rather than
roviding a copy-constructor with the wrong semantics. More
nformation is available in a separate file, COPYNOTE.
he current version is moderately robust. It will for example break
own if you allocate arrays where the number of elements is >MAXINT,
r if the total allocated space overflows a size_t.
t is also worth pointing out that Array<T>::size() returns the number
f elements, not the total size of the storage occupied by the array.
uthor.
ag Bruck, Department of Automatic Control, Lund Institute of
echnology, Box 188, S-221 00 Lund, Sweden. E-mail: dag@control.lth.se
cknowledgements.
would like to thank Tom Cargill and John Skaller for comments on the
riginal version. The current version, and even more so, the next
ersion, benefits from feedback from actual and potential users..